package com.liunian.algorithmstudy.tree;

public class IsValidBST98 extends TreeNode {
	long max_value = Long.MIN_VALUE;
	public boolean isValidBST(TreeNode root) {
		if (root == null) {
			return true;
		}
		boolean leftB = isValidBST(root.left);
		if (root.val > max_value) {
			max_value = root.val;
		} else {
			return false;
		}
		boolean rightB = isValidBST(root.right);
		return leftB && rightB;
	}

}
